//
//  LBJoinRoomViewController.m
//  LBTILiveSDK_Example
//
//  Created by 刘文扬 on 2018/3/14.
//  Copyright © 2018年 刘文扬. All rights reserved.
//

#import "LBJoinRoomViewController.h"
#import <LBTILiveSDK/LBAVBaseView.h>

#import <LBAlert.h>

@interface LBJoinRoomViewController ()

/** avView*/
@property(nonatomic,strong)LBAVBaseView *avView;

@end

@implementation LBJoinRoomViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self.view addSubview:self.avView];
    
    
    __weak LBJoinRoomViewController *weakSelf = self;
    [LBAlert showInputTextFieldWithMessage:nil limit:20 placeholder:@"加入房间号" buttons:@[@"取消",@"确定"] block:^(LBAlertInputTextField *input, NSInteger answer) {
        if (answer == 0) {
            
            [weakSelf.navigationController popViewControllerAnimated:YES];
        }else{
            weakSelf.title = input.textField.text;
            [weakSelf startPlayWithRoomId:input.textField.text];
        }
    }];
    
    
    
    
    
    // Do any additional setup after loading the view, typically from a nib.
}

-(void)startPlayWithRoomId:(NSString *)roomId
{
    
    self.avView.role = self.isLive ? LBAVRoleGuest : LBAVRoleInteractGuest;
    self.avView.roomId = roomId;
    [self.avView startDisplay];
}

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

-(LBAVBaseView *)avView
{
    if (_avView == nil) {
        
        _avView = [[LBAVBaseView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
        
    }
    return _avView;
}


-(void)dealloc
{
    [[LBTILiveManager shareManager] releaseResouce];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
